#include "com.hpp"
#define NAMED_PIPE "/tmp/mypipe.110"
int main()
{
    bool r = creatFifo(NAMED_PIPE);
    assert(r);
    (void)r;

    int rfd = open(NAMED_PIPE, O_RDONLY);
    if(rfd < 0)exit(1);
    char buffer[1024];
    //read
    while(1)
    {
        ssize_t s = read(rfd , buffer ,sizeof(buffer)-1);
        if(s > 0)
        {
            buffer[s] = 0;
            cout<<"client -> server# "<<buffer<<endl;
        }
        else if(s == 0)
        {
            cout<<"client quit, me too! "<<endl;
            break;
        }
        else
        {
            //cout<<"err string : "<<strerror(errno)<<endl;
            break;
        }
    }
    close(rfd);
    sleep(1);
    removeFifo(NAMED_PIPE);
    return 0;
}